-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update tests to stop relying on DiagnosticAnalyzerTestBase #2988
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like your editor is misconfigured to make whitespace changes unrelated to the rest of the pull request. I stopped the review after a few files due to the high level of noise caused by this. If the editor was Visual Studio and there is no extension in use that was causing these changes, we will definitely want to get a bug filed to force it to stop this.
...soft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/AddLanguageSupportToAnalyzerRuleTests.cs
Outdated
Show resolved
Hide resolved
...odeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingDiagnosticAnalyzerAttributeRuleTests.cs
Outdated
Show resolved
Hide resolved
...icrosoft.CodeAnalysis.Analyzers/UnitTests/FixAnalyzers/FixerWithFixAllAnalyzerTests.Fixer.cs
Outdated
Show resolved
Hide resolved
...osoft.NetCore.Analyzers/UnitTests/Tasks/DoNotCreateTasksWithoutPassingATaskSchedulerTests.cs
Outdated
Show resolved
Hide resolved
@sharwell Sorry for the time waste. I did all the changes without thinking to disable some of the extensions. I am used to rely on them for git development as they help avoiding those kind of space/tab or trailing space "issue". If that's ok for you I will do a revert, un-stage all spaces and force-push right after. |
4d59ac7
to
1bba41a
Compare
@Evangelink If you are OK with it, I should be able to selectively revert those lines as long as you are OK with me force-pushing to your verifycs-test branch. Let me know if you would prefer I do that. If you are comfortable with it, please feel free to force-push to this PR to make the change. |
@sharwell Of course I am fine with you doing some changes as needed in this PR. There were too many conflict with the master branch (because of the culture for the string format) + all those incorrect spaces/tabs issues so I went for a rebase + re-apply of all changes 1 by 1. Hopefully everything shall be alright for you to review. |
src/Microsoft.CodeAnalysis.Analyzers/UnitTests/FixAnalyzers/FixerWithFixAllAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.CodeAnalysis.Analyzers/UnitTests/FixAnalyzers/FixerWithFixAllAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
...ality.Analyzers/UnitTests/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructorsTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AvoidEmptyInterfacesTests.cs
Outdated
Show resolved
Hide resolved
...lity.Analyzers/UnitTests/ApiDesignGuidelines/DoNotDeclareStaticMembersOnGenericTypesTests.cs
Outdated
Show resolved
Hide resolved
...t.CodeQuality.Analyzers/UnitTests/Maintainability/AvoidUninstantiatedInternalClassesTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/DoNotIgnoreMethodResultsTests.cs
Show resolved
Hide resolved
...t.CodeQuality.Analyzers/UnitTests/QualityGuidelines/ValidateArgumentsOfPublicMethodsTests.cs
Outdated
Show resolved
Hide resolved
...t.CodeQuality.Analyzers/UnitTests/QualityGuidelines/ValidateArgumentsOfPublicMethodsTests.cs
Show resolved
Hide resolved
...t.CodeQuality.Analyzers/UnitTests/QualityGuidelines/ValidateArgumentsOfPublicMethodsTests.cs
Outdated
Show resolved
Hide resolved
@Evangelink I was able to complete the review. Please avoid rebasing at this point so the updates are straightforward to review. 👍 |
It would be nice to have some info about the failing tests in the CI, they are all green locally so it's a bit hard to understand what's wrong. |
Does this show for you? https://dev.azure.com/dnceng/public/_build/results?buildId=411650&view=ms.vss-test-web.build-test-results-tab It should appear from this link: |
VisualBasic_ProtectedVariable_PublicContainingType
|
...odeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotDeclareVisibleInstanceFieldsTests.cs
Outdated
Show resolved
Hide resolved
...odeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotDeclareVisibleInstanceFieldsTests.cs
Outdated
Show resolved
Hide resolved
@Evangelink apparently just one test class is causing problems. The two specific changes I mentioned just now should resolve the test failures, and then we can merge this. |
@sharwell I was actually looking at the logs and couldn't find anything except the error lines (without any detail on the failing tests), I totally forgot to look at the |
Motivation
In one of the PR review, @sharwell said that inheriting from
DiagnosticAnalyzerTestBase
was the old (obsolete?) way of doing tests. Some preparation for the migration was already done by adding the static usings for C# and VB.NET.This PR tries to replace most of the old usages with the new recommended.
What's left
There is still some work left but I am not sure whether this shall be done within this PR or into some other. Also, I need some input from you to move forward on some points.
Non migrated tests
Some tests are not migrated because:
usage of the scope notation doesn't seem to be working properly. I didn't spend time to do investigate what was the issue. I will try to do so later on.
some tests explicitly force the parse option to
null
, although I think I might have found a way to do the same thing with the new syntax, I am not sure about it.something wasn't working properly when multiple "files" were givenI missed some test classes
AD0001
The following tests from
ReviewUnusedParametersTests.cs
:public async Task DiagnosticForUnusedLocalFunctionParameters_01()
public async Task DiagnosticForUnusedLocalFunctionParameters_02()
public async Task NoDiagnosticUsedLocalFunctionParameters()
are failing with the following error:
error AD0001: Analyzer 'Microsoft.CodeQuality.Analyzers.Maintainability.ReviewUnusedParametersAnalyzer' threw an exception of type 'System.ArgumentException' with message 'The key already existed in the dictionary.'.
I will create a ticket to handle this issue but I am not sure whether to revert the failing tests to the old way or to skip them for the time being. WDYT?Miscellaneous
In some tests the callers always provide the same rule, it could be move directly to the get diagnostic result method.
Some tests need to be updated to use the descriptor instead of the ID.
I am not sure whether tests shall be using
new DiagnosticResult()
orVerifyCS.Diagnostic()
Hope this PR is going the right direction and helps you!